package com.jk.smartelderlycare.controller;

import com.jk.smartelderlycare.dto.SysSign;
import com.jk.smartelderlycare.pojo.PagedResponse;
import com.jk.smartelderlycare.pojo.ResponseResult;
import com.jk.smartelderlycare.service.SysSignServiceFeign;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author hhk
 * @version 1.0
 * @ClassName SysSignController
 * @program: smart-elderly-care
 * @description: TODO
 * @date 2024/11/15 15:41
 */
@Api(tags = "报名管理模块")
@RestController
@CrossOrigin
@RequestMapping(value = "sysSign")
public class SysSignController {
    @Autowired
    private SysSignServiceFeign sysSignServiceFeign;

    /**
     * @description: 报名列表后端分页查询
     * @param: [sysSign, pageNum, pageSize]
     * @return: com.jk.smartelderlycare.pojo.ResponseResult<com.jk.smartelderlycare.pojo.PagedResponse<com.jk.smartelderlycare.dto.SysSign>>
     * @author hhk
     * @date: 2024/11/15 15:44
     */
    @ApiOperation(value = "报名列表后端分页查询",httpMethod = "POST",notes = "报名列表后端分页查询")
    @PostMapping(value = "findSysSignPaginationList")
    private ResponseResult<PagedResponse<SysSign>> findSysSignPaginationList(@RequestBody SysSign sysSign,@RequestParam(value = "pageNum") Integer pageNum,@RequestParam(value = "pageSize") Integer pageSize){
        return new ResponseResult<>(200,"查询成功",sysSignServiceFeign.findSysSignPaginationList(sysSign,pageNum,pageSize));
    }

    /**
     * @description: 审核通过
     * @param: [signId]
     * @return: void
     * @author hhk
     * @date: 2024/11/15 15:45
     */
    @ApiOperation(value = "报名状态修改",httpMethod = "PUT",notes = "报名状态修改")
    @PutMapping(value = "updateStatusById")
    private ResponseResult updateStatusById(@RequestParam Long signId){
        try {

            sysSignServiceFeign.updateStatusById(signId);
            return new ResponseResult(200,"修改成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult(500,"修改失败");
        }
    }

    /**
     * @description: 审核未通过
     * @param: [signId]
     * @return: com.jk.smartelderlycare.dto.SysSign
     * @author hhk
     * @date: 2024/11/15 15:46
     */
    @ApiOperation(value = "报名详情",httpMethod = "PUT",notes = "报名详情")
    @PutMapping(value = "alStatusById")
    private ResponseResult alStatusById(@RequestParam Long signId){
        try {
            sysSignServiceFeign.alStatusById(signId);
            return new ResponseResult(200,"修改成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult(500,"修改失败");
        }
    }

    @ApiOperation(value = "报名删除",httpMethod = "DELETE",notes = "报名删除")
    @DeleteMapping(value = "deleteSysSignById")
    private ResponseResult deleteSysSignById(@RequestParam Long signId){
        try {
            sysSignServiceFeign.deleteSysSignById(signId);
            return new ResponseResult(200,"删除成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult(500,"删除失败");
        }
    }
}
